﻿using Gwn.Library.MvpVm.Base;
using Gwn.Library.MvpVm.Constants;
using Gwn.Library.MvpVm.Interfaces;
using Gwn.Library.MvpVm.ViewModels;
using Gwn.Library.MvpVm.Views;
using Gwn.Module.UserManager.Commands;
using Gwn.Module.UserManager.Interfaces;
using Gwn.Module.UserManager.Layers;
using Microsoft.Practices.Unity;

namespace Gwn.Module.UserManager
{
    public class UserManagerModule : ModuleBase
    {
        protected override void RegisterTypes()
        {
            base.RegisterTypes();

            // Register the presenter, view and viewModel
            Container
                .RegisterType<IView, ViewModelHolderView>()         // Shared view 
                .RegisterType<IViewModel, UserCommandViewModel>()   // Shared view model
                .RegisterType<IPresenter, UserManagerPresenter>()

                // Commands - we'll use Unity like a factory.  We can resolve IPresenterCommand by name
                .RegisterType<IPresenterCommand, UserManagerCommand>(ConstantUserManager.UserManagerAdd)
                .RegisterType<IPresenterCommand, UserManagerCommand>(ConstantUserManager.UserManagerEdit)
                .RegisterType<IPresenterCommand, UserManagerCommand>(ConstantUserManager.UserManagerUndo)
                .RegisterType<IPresenterCommand, UserManagerCommand>(ConstantUserManager.UserManagerSave)
                .RegisterType<IPresenterCommand, UserManagerCommand>(ConstantUserManager.UserManagerDelete)
                .RegisterType<IPresenterCommand, ActivateLoginViewCommand>(ConstantSecurity.ActivateLoginView)

                // Singletons
                .RegisterType<IBusinessLogicLayer, MockBll>(new ContainerControlledLifetimeManager())
                .RegisterType<IDataAccessLayer, DataAccessLayer>(new ContainerControlledLifetimeManager())
                ;
        }
    }
}
